<template>
	<el-dialog title="资产审批对话框" v-model="visible" :width="500" destroy-on-close @closed="$emit('closed')">
		<el-form :model="form" :rules="rules" ref="dialogForm" label-width="80px" label-position="left">
			<el-form-item label="申请标题" prop="title">
				{{title}}
			</el-form-item>
			<el-form-item label="资产名称">{{ assetsName }}</el-form-item>
			<el-form-item label="资产编号">{{ assetsCode }}</el-form-item>
			<el-form-item label="品牌">{{ brand }}</el-form-item>
			<el-form-item label="型号">{{ model }}</el-form-item>
			<el-form-item label="使用人" prop="usedUser">
				{{usedUserName}}
			</el-form-item>
			<el-form-item label="使用部门" prop="usedDept">
				{{usedDeptName}}
			</el-form-item>
			<el-form-item label="审批意见" prop="status">
				<el-radio-group v-model="form.status">
					<el-radio-button label="1">同意</el-radio-button>
					<el-radio-button label="2">不同意</el-radio-button>
				</el-radio-group>
			</el-form-item>
			<el-form-item label="备注">
				<el-input v-model="form.ideaText" type="textarea" placeholder="备注说明" maxlength="180" clearable></el-input>
			</el-form-item>
		</el-form>
		<template #footer>
			<el-button @click="visible=false">取 消</el-button>
			<el-button type="primary" :loading="isSaveing" @click="submit()">保 存</el-button>
		</template>
	</el-dialog>
</template>

<script>
import selectUserDialog from "@/views/module/selectUserDialog";
import selectDeptDialog from "@/views/module/selectDeptDialog";

export default {
	components: {
		selectUserDialog,
		selectDeptDialog
	},
	emits: ['success', 'closed'],
	data() {
		return {
			visible: false,
			isSaveing: false,
			applyId: '',
			title:'',
			assetsName: '',
			assetsCode: '',
			usedUserName: '',
			usedDeptName: '',
			brand:'',
			model:'',
			form: {
				applyId:'',
				status:"1",
				ideaText: ""
			},
			rules: {
			},
		}
	},
	mounted() {
	},
	methods: {
		//显示
		open() {
			this.visible = true;
			return this;
		},
		//表单提交方法
		submit() {
			this.$refs.dialogForm.validate(async (valid) => {
				if (valid) {
					this.isSaveing = true;
					var res = await this.$API.office.fixed.approvalFixedAssetsApply.post(this.form);
					this.isSaveing = false;
					if (res.code == 200) {
						this.$emit('success')
						this.visible = false;
						this.$message.success("操作成功")
					} else {
						this.$alert(res.message, "提示", {type: 'error'})
					}
				}
			})
		},
		//表单注入数据
		setData(data) {
			this.applyId = data.applyId
			this.title = data.title
			this.brand = data.brand
			this.model = data.model
			this.assetsName = data.assetsName
			this.assetsCode = data.assetsCode
			this.usedUserName = data.usedUserName
			this.usedDeptName = data.usedDeptName
			this.form.applyId = data.applyId
		}
	}
}
</script>

<style>
</style>
